# -*- coding: utf-8 -*-
"""
@Time ： 2021/7/30 0:06
@Auth ： Mr.掌心 2929184523
@Company ：特斯汀学院 @testingedu.com.cn
@Function ：请输入模块功能描述
"""
from PO.pages.base_page import BasePage


class AddressPage(BasePage):
    AddressPage_locators = {
        '_add_address_locator': '//span[text()="增加新地址"]',
        '_user_name_locator': '//input[@name="consignee"]',
        '_user_phone_locator': '//input[@name="mobile"]',
        '_province_locator': '//*[@id="province"]',
        '_city_locator': '//*[@id="city"]',
        '_district_locator': '//*[@id="district"]',
        '_twon_locator': '//*[@id="twon"]',
        '_detailed_address_locator': '//input[@name="address"]',
        '_zipcode_locator': '//input[@name="zipcode"]',
        '_submit_locator': '//*[@id="address_submit"]',
    }

    def add_address(self,name,phone,province,city,district,twon,detailed_address,zipcode):
        self.driver.get('http://testingedu.com.cn:8000/Home/User/address_list.html')
        self.clickjs(self.AddressPage_locators['_add_address_locator'])
        self.input(self.AddressPage_locators['_user_name_locator'], name)
        self.input(self.AddressPage_locators['_user_phone_locator'], phone)
        self.select(self.AddressPage_locators['_province_locator'], province)
        self.select(self.AddressPage_locators['_city_locator'], city)
        self.select(self.AddressPage_locators['_district_locator'], district)
        self.select(self.AddressPage_locators['_twon_locator'], twon)
        self.input(self.AddressPage_locators['_detailed_address_locator'], detailed_address)
        self.input(self.AddressPage_locators['_zipcode_locator'], zipcode)
        self.clickjs(self.AddressPage_locators['_submit_locator'])

    def del_address(self, name):
        self.clickjs(f'//span[text()="{name}"]/../..//a[text()="删除"]')
